package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import lombok.extern.slf4j.Slf4j;
import com.sc.nft.entity.TaskAppointProduct;
import com.sc.nft.mapper.TaskAppointProductMapper;
import  com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * (sc_task_appoint_product)数据DAO
 *
 * @author zxy
 * @since 2023-11-10 20:31:35
 * @description 商户banner
 */
@Slf4j
@Repository
public class TaskAppointProductDao extends ServiceImpl<TaskAppointProductMapper, TaskAppointProduct> {

    public void clearByTaskId(Long taskId){
        LambdaUpdateWrapper<TaskAppointProduct> wrapper = new LambdaUpdateWrapper<>();
        wrapper.eq(TaskAppointProduct::getTaskId,taskId);
        remove(wrapper);
    }

    public List<TaskAppointProduct> getByTaskId(Long taskId){
        return lambdaQuery().eq(TaskAppointProduct::getTaskId,taskId).list();
    }

    public boolean existsAppointProduct(Long taskId,Long linkId){
        LambdaQueryWrapper<TaskAppointProduct> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(TaskAppointProduct::getTaskId,taskId);
        wrapper.eq(TaskAppointProduct::getLinkId,linkId);
        return count(wrapper)>0;
    }

}